 package server;

 import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import provider.MapleData;
 import provider.MapleDataProviderFactory;
 import provider.MapleDataTool;
 import tools.Pair;


 public class ItemMakerFactory
 {
/*  16 */   private static final ItemMakerFactory instance = new ItemMakerFactory();
/*  17 */   protected final Map<Integer, ItemMakerCreateEntry> createCache = new HashMap<>();
/*  18 */   protected final Map<Integer, GemCreateEntry> gemCache = new HashMap<>();




   protected ItemMakerFactory() {
/*  24 */     MapleData info = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Etc.wz")).getData("ItemMake.img");






/*  31 */     for (MapleData dataType : info.getChildren()) {
/*  32 */       int type = Integer.parseInt(dataType.getName());
/*  33 */       switch (type) {
         case 0:
/*  35 */           for (MapleData itemFolder : dataType.getChildren()) {
/*  36 */             int reqLevel = MapleDataTool.getInt("reqLevel", itemFolder, 0);
/*  37 */             byte reqMakerLevel = (byte)MapleDataTool.getInt("reqSkillLevel", itemFolder, 0);
/*  38 */             int cost = MapleDataTool.getInt("meso", itemFolder, 0);
/*  39 */             int quantity = MapleDataTool.getInt("itemNum", itemFolder, 0);

/*  41 */             GemCreateEntry ret = new GemCreateEntry(cost, reqLevel, reqMakerLevel, quantity);
/*  42 */             for (MapleData rewardNRecipe : itemFolder.getChildren()) {
/*  43 */               for (MapleData ind : rewardNRecipe.getChildren()) {
/*  44 */                 if (rewardNRecipe.getName().equals("randomReward")) {
/*  45 */                   ret.addRandomReward(MapleDataTool.getInt("item", ind, 0), MapleDataTool.getInt("prob", ind, 0)); continue;
                 }
/*  47 */                 if (rewardNRecipe.getName().equals("recipe")) {
/*  48 */                   ret.addReqRecipe(MapleDataTool.getInt("item", ind, 0), MapleDataTool.getInt("count", ind, 0));
                 }
               }
             }
/*  52 */             this.gemCache.put(Integer.valueOf(Integer.parseInt(itemFolder.getName())), ret);
           }


         case 1:
         case 2:
         case 4:
         case 8:
         case 16:
/*  61 */           for (MapleData itemFolder : dataType.getChildren()) {
/*  62 */             int reqLevel = MapleDataTool.getInt("reqLevel", itemFolder, 0);
/*  63 */             byte reqMakerLevel = (byte)MapleDataTool.getInt("reqSkillLevel", itemFolder, 0);
/*  64 */             int cost = MapleDataTool.getInt("meso", itemFolder, 0);
/*  65 */             int quantity = MapleDataTool.getInt("itemNum", itemFolder, 0);
/*  66 */             byte totalupgrades = (byte)MapleDataTool.getInt("tuc", itemFolder, 0);
/*  67 */             int stimulator = MapleDataTool.getInt("catalyst", itemFolder, 0);
/*  68 */             ItemMakerCreateEntry imt = new ItemMakerCreateEntry(cost, reqLevel, reqMakerLevel, quantity, totalupgrades, stimulator);
/*  69 */             for (MapleData Recipe : itemFolder.getChildren()) {
/*  70 */               for (MapleData ind : Recipe.getChildren()) {
/*  71 */                 if (Recipe.getName().equals("recipe")) {
/*  72 */                   imt.addReqItem(MapleDataTool.getInt("item", ind, 0), MapleDataTool.getInt("count", ind, 0));
                 }
               }
             }
/*  76 */             this.createCache.put(Integer.valueOf(Integer.parseInt(itemFolder.getName())), imt);
           }
       }
     }
   }




   public static ItemMakerFactory getInstance() {
/*  86 */     return instance;
   }

   public GemCreateEntry getGemInfo(int itemid) {
/*  90 */     return this.gemCache.get(Integer.valueOf(itemid));
   }

   public ItemMakerCreateEntry getCreateInfo(int itemid) {
/*  94 */     return this.createCache.get(Integer.valueOf(itemid));
   }

   public static class GemCreateEntry
   {
     private final int reqLevel;
     private final int reqMakerLevel;
     private final int cost;
     private final int quantity;
/* 103 */     private final List<Pair<Integer, Integer>> randomReward = new ArrayList<>();
/* 104 */     private final List<Pair<Integer, Integer>> reqRecipe = new ArrayList<>();

     public GemCreateEntry(int cost, int reqLevel, int reqMakerLevel, int quantity) {
/* 107 */       this.cost = cost;
/* 108 */       this.reqLevel = reqLevel;
/* 109 */       this.reqMakerLevel = reqMakerLevel;
/* 110 */       this.quantity = quantity;
     }

     public int getRewardAmount() {
/* 114 */       return this.quantity;
     }

     public List<Pair<Integer, Integer>> getRandomReward() {
/* 118 */       return this.randomReward;
     }

     public List<Pair<Integer, Integer>> getReqRecipes() {
/* 122 */       return this.reqRecipe;
     }

     public int getReqLevel() {
/* 126 */       return this.reqLevel;
     }

     public int getReqSkillLevel() {
/* 130 */       return this.reqMakerLevel;
     }

     public int getCost() {
/* 134 */       return this.cost;
     }

     protected void addRandomReward(int itemId, int prob) {
/* 138 */       this.randomReward.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(prob)));
     }

     protected void addReqRecipe(int itemId, int count) {
/* 142 */       this.reqRecipe.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(count)));
     }
   }

   public static class ItemMakerCreateEntry
   {
     private final int reqLevel;
     private final int cost;
     private final int quantity;
     private final int stimulator;
     private final byte tuc;
     private final byte reqMakerLevel;
/* 154 */     private final List<Pair<Integer, Integer>> reqItems = new ArrayList<>();
/* 155 */     private final List<Integer> reqEquips = new ArrayList<>();

     public ItemMakerCreateEntry(int cost, int reqLevel, byte reqMakerLevel, int quantity, byte tuc, int stimulator) {
/* 158 */       this.cost = cost;
/* 159 */       this.tuc = tuc;
/* 160 */       this.reqLevel = reqLevel;
/* 161 */       this.reqMakerLevel = reqMakerLevel;
/* 162 */       this.quantity = quantity;
/* 163 */       this.stimulator = stimulator;
     }

     public byte getTUC() {
/* 167 */       return this.tuc;
     }

     public int getRewardAmount() {
/* 171 */       return this.quantity;
     }

     public List<Pair<Integer, Integer>> getReqItems() {
/* 175 */       return this.reqItems;
     }

     public List<Integer> getReqEquips() {
/* 179 */       return this.reqEquips;
     }

     public int getReqLevel() {
/* 183 */       return this.reqLevel;
     }

     public byte getReqSkillLevel() {
/* 187 */       return this.reqMakerLevel;
     }

     public int getCost() {
/* 191 */       return this.cost;
     }

     public int getStimulator() {
/* 195 */       return this.stimulator;
     }

     protected void addReqItem(int itemId, int amount) {
/* 199 */       this.reqItems.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(amount)));
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\server\ItemMakerFactory.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */